package cn.wind.xboot.framework.captcha;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * <p>Title: LuosimaoUtil</p>
 * <p>Description: TODO</p>
 *
 * @author xukk
 * @version 1.0
 * @date 2018/9/5
 */
public class LuosimaoUtil {
    private static final String apiKey="884de71a889394286148954e94fdb4d2";
    private static final String verifyUrl="https://captcha.luosimao.com/api/site_verify";
    public static boolean verify(String response){
        Map map= Maps.newHashMap();
        map.put("api_key",apiKey);
        map.put("response",response);
        String data=HttpUtil.post(verifyUrl,map);
        JSONObject jsonObject=JSONObject.parseObject(data);
        if("success".equalsIgnoreCase(jsonObject.getString("res"))){
            return true;
        }else {
            return false;
        }
    }
}
